<%@ page import="org.xilin.Student" %>
<%@ page import="org.xilin.Family" %>

<g:setProvider library="jquery"/>

<div>
    <g:if test="${flash.message}">
      <div class="message" style="display:none">${flash.message}</div>
    </g:if>
    <g:hasErrors>
      <div class="errors">
          <g:renderErrors bean="${studentInstance}" as="list" />
      </div>
    </g:hasErrors>
    <g:formRemote name="saveFamily" url="${[action:'adminSave']}" method="post" update="cluetip-inner" before="beforeSave()" onComplete="processResponse({cluetipWidth:'600px', cluetipHeight:'500px'})">
        <g:hiddenField name="view" value="adminCreate" />
        <g:hiddenField name="id" value="${studentInstance?.id}" />
        <div class="dialog">
            <table>
                <tbody>
                    <tr class="prop">
                      <td valign="top" class="name">
                          <label for="family.id"><g:message code="student.family.label" default="Family" /></label>
                      </td>
                      <td valign="top" class="value ${hasErrors(bean: studentInstance, field: 'studentInstance?.family?.id', 'errors')}">
                          <g:select name="family.id" from="${org.xilin.Family.list()}" optionKey="id" value="${studentInstance?.family?.id}"  />
                      </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="firstName"><g:message code="student.firstName.label" default="First Name" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: studentInstance, field: 'firstName', 'errors')}">
                          <g:textField name="firstName" value="${studentInstance?.firstName}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="lastName"><g:message code="student.lastName.label" default="Last Name" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: studentInstance, field: 'lastName', 'errors')}">
                          <g:textField name="lastName" value="${studentInstance?.lastName}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="chineseName"><g:message code="student.chineseName.label" default="Chinese Name" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: studentInstance, field: 'chineseName', 'errors')}">
                          <g:textField name="chineseName" value="${studentInstance?.chineseName}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="birthDay"><g:message code="student.birthDye.label" default="Birth Date" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: studentInstance, field: 'birthDay', 'errors')}">
                            <g:textField class="date-pick" name="birthDay" value="${fieldValue(bean: studentInstance, field: 'birthDay')}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="gender"><g:message code="student.gender.label" default="Gender" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: studentInstance, field: 'gender', 'errors')}">
                          <g:select name="gender" from="${['F','M']}" />                          
                        </td>
                    </tr>

                </tbody>
            </table>
        </div>
        <br/>
        <div class="buttons">
            <span class="button"><g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Save')}" /></span>
            <span class="button"><input type="reset" value="${message(code: 'default.button.clear.label', default: 'Reset')}" /></span>
        </div>
    </g:formRemote>
</div>